// JavaScript Document

var boton = {
    init : function() {
        if (!document.getElementById || !document.createElement || !document.appendChild) return false;
        as = boton.getElementsByClassName('boton(.*)');
        for (i=0; i<as.length; i++) {
            if ( as[i].tagName == "INPUT" && ( as[i].type.toLowerCase() == "submit" || as[i].type.toLowerCase() == "button" ) ) {
                var a1 = document.createElement("a");
                a1.appendChild(document.createTextNode(as[i].value));
                a1.className = as[i].className;
                a1.id = as[i].id;
                as[i] = as[i].parentNode.replaceChild(a1, as[i]);
                as[i] = a1;
                as[i].style.cursor = "pointer";
            }
            else if (as[i].tagName == "A") {
                var tt = as[i].childNodes;
            }
            else { return false };
            var i1 = document.createElement('i');
            var i2 = document.createElement('i');
            var s1 = document.createElement('span');
            var s2 = document.createElement('span');
            s1.appendChild(i1);
            s1.appendChild(s2);
            while (as[i].firstChild) {
              s1.appendChild(as[i].firstChild);
            }
            as[i].appendChild(s1);
            as[i] = as[i].insertBefore(i2, s1);
        }
		// The following lines submits the form if the button id is "submit_boton"
        boton.addEvent(document.getElementById('submit_boton'),'click',function() {
            var form = boton.findForm(this);
            form.submit();
        });
        // The following lines resets the form if the button id is "reset_boton"
        boton.addEvent(document.getElementById('reset_boton'),'click',function() {
            var form = boton.findForm(this);
            form.reset();
        });
        // The following lines resets the form if the button id is "reset_boton"
        boton.addEvent(document.getElementsByTagName('a'),'click',function() {
            var lnk = boton.findT(this);
            lnk.href;
        });
		
    },
    findForm : function(f) {
        while(f.tagName != "FORM") {
            f = f.parentNode;
        }
        return f;
    },
    findT : function(a) {
        while(a.tagName != "a") {
            a = a.parentNode;
        }
        return a;
    },
    addEvent : function(obj, type, fn) {
        if (obj.addEventListener) {
            obj.addEventListener(type, fn, false);
        }
        else if (obj.attachEvent) {
            obj["e"+type+fn] = fn;
            obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
            obj.attachEvent("on"+type, obj[type+fn]);
        }
    },
    getElementsByClassName : function(className, tag, elm) {
        var testClass = new RegExp("(^|\s)" + className + "(\s|$)");
        var tag = tag || "*";
        var elm = elm || document;
        var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
        var returnElements = [];
        var current;
        var length = elements.length;
        for(var i=0; i<length; i++){
            current = elements[i];
            if(testClass.test(current.className)){
                returnElements.push(current);
            }
        }
        return returnElements;
    }
}

boton.addEvent(window,'load', function() { boton.init();} );


  function setActiveStyleSheet(title) 
  { 
          var i, a, main; 
 
          for( i = 0; (a = document.getElementsByTagName("link")[i]); i++) 
          { 
                  if( a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") ) 
                  { 
                          a.disabled = true; 
 
                          if(a.getAttribute("title") == title) a.disabled = false; 
                  } 
          } 
  } 
 
  function getActiveStyleSheet() 
  { 
          var i, a; 
 
          for( i=0; (a = document.getElementsByTagName("link")[i]); i++ ) 
          { 
                  if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title"); 
 
          } 
          return null; 
  } 
   
  function getPreferredStyleSheet() 
  { 
          var i, a; 
 
          for( i = 0; (a = document.getElementsByTagName("link")[i]); i++ ) 
          { 
                  if( a.getAttribute("rel").indexOf("style") != -1 
                  && a.getAttribute("rel").indexOf("alt") == -1 
                  && a.getAttribute("title") )  
                  return a.getAttribute("title"); 
          } 
          return null; 
  } 
 
  function createCookie(name,value,days) 
  { 
          if (days) 
          { 
                  var date = new Date(); 
                  date.setTime(date.getTime()+(days*24*60*60*1000)); 
                  var expires = "; expires="+date.toGMTString(); 
          } 
          else expires = ""; 
 
          document.cookie = name+"="+value+expires+"; path=/"; 
  } 
 
  function readCookie(name) 
  { 
          var nameEQ = name + "="; 
          var ca = document.cookie.split(';'); 
 
          for( var i=0; i < ca.length; i++ ) 
          { 
                  var c = ca[i]; 
 
                  while (c.charAt(0)==' ') c = c.substring(1,c.length); 
 
                  if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 
          } 
          return null; 
  } 
 
  window.onload = function(e) 
  { 
          var cookie = readCookie("illuticStyle"); 
 
          var title = cookie ? cookie : getPreferredStyleSheet(); 
 
          setActiveStyleSheet(title); 
  } 
 
  window.onunload = function(e) 
  { 
          var title = getActiveStyleSheet(); 
 
          createCookie("illuticStyle", title, 365); 
  } 
 
  var cookie = readCookie("illuticStyle"); 
  var title = cookie ? cookie : getPreferredStyleSheet(); 
 
  setActiveStyleSheet(title); 